# SelectionSort20211107.py

def find_min_index(array, i):
  min_index = i

  for j in range(i + 1, len(array)):
    if array[j] < array[min_index]:
      min_index = j
  
  return min_index

def selection_sort(array):
  for i in range(0, len(array) - 1):
    min_index = find_min_index(array, i)

    array[i], array[min_index] = array[min_index], array[i]
  
  return array
